#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct big_happy_tou
{
    int red[5];
    int blue[2];
}tiyu_caipiao;

void a_mi_tuo_fo(tiyu_caipiao * cai_piao);

void print_struct(tiyu_caipiao * cai_piao);

int comp(const void *a,const void*b)
{
    return *(int *)a - *(int *)b;
}

int main(int argc,char *argv[])
{
	int count = 270;
    	srand(time(NULL));
	int j;
	for(j=0;j<count;j++)
	{
    		tiyu_caipiao t1[1] = {0};
    		for(int i = 0;i < 1;i++)
    		{
        		a_mi_tuo_fo(&t1[i]);
    		}
    		print_struct(t1);
		if(j < count-1)
			puts(" ---------------------------");
	}
    return EXIT_SUCCESS;
}

void print_struct(tiyu_caipiao * cai_piao)
{
    int i;
    for(i = 0;i < 1;i++)
    {
        int j;
        for(j=0;j<5;j++)
        {
            printf(" %02d " , cai_piao[i].red[j]);
        }
        printf("+");
        for(j=0;j<2;j++)
        {
            printf(" %02d " , cai_piao[i].blue[j]);
        }
        printf("\n");
    }
}

void tian_chong(int * arr,int confines,int num_count)
{
    int c_count = 0;
    for(;;)
    {
        int result = rand() % confines + 1;
        if(c_count == num_count)
            break;
        int i;
        int flag = 0;
        for(i=0;i<c_count;i++)
        {
            if(arr[i] == result)
            {
                flag = 1;
                break;
            }
        }
        if(!flag)
        {
            arr[c_count] = result;
            c_count++;
        }
    }
    qsort(arr,num_count,sizeof(int),comp);
}

void a_mi_tuo_fo(tiyu_caipiao * cai_piao)
{
    tian_chong(cai_piao->red,34,5);
    tian_chong(cai_piao->blue,11,2);
}
